<template>
  <input-checkbox :value="val" :field="field" :disabled="disabled" @input="onChange"></input-checkbox>
</template>

<script>
  import InputCheckbox from '../../dynamic-form/input-types/InputCheckbox.vue'

  export default {
    components: {InputCheckbox},
    props: {
      label: {},
      value: {
        default: false
      },
      disabled: {
        type: Boolean,
        default: false
      }
    },
    mounted () {
      this.init()
      this.val = this.value
    },
    data () {
      return {
        val: false,
        field: {
        }
      }
    },
    methods: {
      init () {
        this.field = { label: this.label }
      },
      onChange (val) {
        this.$emit('input', val)
      }
    },
    watch: {
      value () {
        this.val = this.value
      },
      label () {
        this.init()
      }
    }
  }
</script>
